package mylab.io.store.mqtt.client;

import mylab.base.foundation.lang.Callback;
import mylab.io.store.mqtt.common.MqttQoS;
import mylab.utils.common.ByteUtil;

public interface MqttPublisher {


    default void publish(String topic, String payload) {
        publish(topic, ByteUtil.stringToBytes(payload));
    }

    default void publish(String topic, byte[] payload) {
        publish(topic, MqttQoS.AT_LEAST_ONCE, payload, null);
    }

    default void publish(String topic, String payload, Callback<Void> callback) {
        publish(topic, ByteUtil.stringToBytes(payload), callback);
    }

    default void publish(String topic, byte[] payload, Callback<Void> callback) {
        publish(topic, MqttQoS.AT_LEAST_ONCE, payload, callback);
    }

    default void publish(String topic, MqttQoS qoS, String payload, Callback<Void> callback) {
        publish(topic, qoS, ByteUtil.stringToBytes(payload), callback);
    }

    void publish(String topic, MqttQoS qoS, byte[] payload, Callback<Void> callback);

}
